package org.assertj.ohos.sample;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.aafwk.content.Intent;
import ohos.account.app.AppAccount;
import ohos.location.GeoAddress;
import org.junit.Test;

import java.util.Locale;

import static org.assertj.ohos.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;

public class ExampleOhosTest {
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("org.assertj.ohos.sample", actualBundleName);
    }

    @Test
    public void testAppAccount() {
        final String account = "testAccountName";
        final String owner = "testOwner";
        assertThat(new AppAccount(account, "testOwner"))
                .hasName(account)
                .hasOwner(owner);
    }

    @Test
    public void testIntent() {
        Intent intent = new Intent();
        intent.setAction("com.test.action");
        intent.setType("com.test.type");
        intent.setParam("test_key", "test_value");

        assertThat(intent)
                .hasAction("com.test.action")
                .hasType("com.test.type")
                .hasExtra("test_key");
    }

    @Test
    public void testGeoAddress() {
        GeoAddress address = new GeoAddress(Locale.getDefault());
        address.setCountryCode("com.test.CountryCode");
        address.setCountryName("com.test.CountryName");
        address.setLatitude(30.0d);
        address.setDescriptions(1, "test_Descriptions");

        assertThat(address)
                .hasCountryCode("com.test.CountryCode")
                .hasCountryName("com.test.CountryName")
                .hasAddressLine(1, "test_Descriptions")
                .hasLatitude();
    }
}